package com.hsc.yalebao.otherlogin;

import android.content.Context;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Looper;
import android.os.Message;
import android.widget.Toast;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import java.util.HashMap;

public class LoginApi
  implements Handler.Callback
{
  private static final int MSG_AUTH_CANCEL = 1;
  private static final int MSG_AUTH_COMPLETE = 3;
  private static final int MSG_AUTH_ERROR = 2;
  private Context context;
  private Handler handler = new Handler(Looper.getMainLooper(), this);
  private OnLoginListener loginListener;
  private String platform;

  public boolean handleMessage(Message paramMessage)
  {
    switch (paramMessage.what)
    {
    default:
    case 1:
    case 2:
    case 3:
    }
    String str1;
    HashMap localHashMap;
    do
    {
      do
        return false;
      while (this.loginListener == null);
      this.loginListener.cancle();
      return false;
      if (this.loginListener != null)
        this.loginListener.cancle();
      Throwable localThrowable = (Throwable)paramMessage.obj;
      String str2 = "caught error: " + localThrowable.getMessage();
      Toast.makeText(this.context, str2, 0).show();
      localThrowable.printStackTrace();
      return false;
      Object[] arrayOfObject = (Object[])paramMessage.obj;
      str1 = (String)arrayOfObject[0];
      localHashMap = (HashMap)arrayOfObject[1];
    }
    while (this.loginListener == null);
    this.loginListener.onLogin(str1, localHashMap);
    return false;
  }

  public void login(Context paramContext)
  {
    this.context = paramContext.getApplicationContext();
    if (this.platform == null);
    Platform localPlatform;
    do
    {
      return;
      ShareSDK.initSDK(paramContext);
      localPlatform = ShareSDK.getPlatform(this.platform);
    }
    while (localPlatform == null);
    if (localPlatform.isAuthValid())
    {
      localPlatform.removeAccount(true);
      return;
    }
    localPlatform.SSOSetting(false);
    localPlatform.setPlatformActionListener(new PlatformActionListener()
    {
      public void onCancel(Platform paramAnonymousPlatform, int paramAnonymousInt)
      {
        if (paramAnonymousInt == 8)
        {
          Message localMessage = new Message();
          localMessage.what = 1;
          localMessage.arg2 = paramAnonymousInt;
          localMessage.obj = paramAnonymousPlatform;
          LoginApi.this.handler.sendMessage(localMessage);
        }
      }

      public void onComplete(Platform paramAnonymousPlatform, int paramAnonymousInt, HashMap<String, Object> paramAnonymousHashMap)
      {
        if (paramAnonymousInt == 8)
        {
          Message localMessage = new Message();
          localMessage.what = 3;
          localMessage.arg2 = paramAnonymousInt;
          Object[] arrayOfObject = new Object[2];
          arrayOfObject[0] = paramAnonymousPlatform.getName();
          arrayOfObject[1] = paramAnonymousHashMap;
          localMessage.obj = arrayOfObject;
          LoginApi.this.handler.sendMessage(localMessage);
        }
      }

      public void onError(Platform paramAnonymousPlatform, int paramAnonymousInt, Throwable paramAnonymousThrowable)
      {
        if (paramAnonymousInt == 8)
        {
          Message localMessage = new Message();
          localMessage.what = 2;
          localMessage.arg2 = paramAnonymousInt;
          localMessage.obj = paramAnonymousThrowable;
          LoginApi.this.handler.sendMessage(localMessage);
        }
        paramAnonymousThrowable.printStackTrace();
      }
    });
    localPlatform.showUser(null);
  }

  public void setOnLoginListener(OnLoginListener paramOnLoginListener)
  {
    this.loginListener = paramOnLoginListener;
  }

  public void setPlatform(String paramString)
  {
    this.platform = paramString;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.otherlogin.LoginApi
 * JD-Core Version:    0.6.2
 */